<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>add</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<script type="text/javascript">
	function submit(){
		var id=document.getElementById("id");
		var account=document.getElementById("account");
		var password=document.getElementById("password");
		var name=document.getElementById("name");
		
		if(id!=null){
			alert("添加成功");
			return submit;
		}else{
			alert("添加失败");
			return false;
		}
	}
	
	function getXhr() {
		var xhr = null;
		if (window.XMLHttpRequest) {
			xhr = new XMLHttpRequest();
		} else {
			xhr = new ActiveXObject("Microsoft.XMLHttp");
		}
		return xhr;
	}

	function check_id(){
		var xhr=getXhr();
		xhr.onreadystatechange=function(){
			if(xhr.readyState==4 && xhr.status==200){
				document.getElementById("id_msg").innerHTML=xhr.responseText;
			}
		};
		xhr.open("post","../servlet/DepServlet?act=isExist",true);
		xhr.setRequestHeader('content-type',
				'application/x-www-form-urlencoded');
		document.getElementById("id_msg").innerHTML="正在检查。。。";
		var id=document.getElementById("id");
		xhr.send("id="+id.value);
	}
	
	
</script>

</head>
<body bgcolor="#FOFOF">
	<form action="../servlet/DepServlet?act=doAdd" method="post">
		<table>
			<tr>
				<td align="right">id:</td>
				<td>
					<input id="id" type="text" name="id" onblur="check_id();" />
					<span style="color: red">*</span>
					<span id="id_msg" style="color:red;"></span>
				</td>
			</tr>
			<tr>
				<td align="right">account:</td>
				<td>
					<input id="account" type="text" name="account" />
					<span style="color: red">*</span> 
				</td>
				
			</tr>
			<tr>
				<td align="right">password:</td>
				<td>
					<input id="password" type="text" name="password">
					<span style="color: red">*</span>
				</td>
			</tr>
			<tr>
				<td align="right">name:</td>
				<td>
					<input id="name" type="text" name="name">
					<span style="color: red">*</span> 
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input type="button" value="添加" onclick="submit();"/><input
					type="reset" value="取消" /><br/><span style="color: red">带*号为必须填写的项</span> </td>
			</tr>
		</table>
	</form>
</body>
</html>
